home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / Terminal 2.2 / Terminal Folder / Log into CIS.s < prev    next >
Text File  |  1990-12-31  |  2KB  |  102 lines

  1. /*
  2.     Terminal 2.0 script
  3.  
  4.     Script to dial and log into CompuServe (via LUXPAC Luxembourg,
  5.     Bern Switzerland) and to automatically open a new capture file
  6.     to save the session.
  7.  
  8.     "Log into CIS.s"
  9. */
  10.  
  11. int TIMEOUT = 1800;    /* 30 seconds */
  12.  
  13. /* ----- Send command and wait for reply ------------------------------- */
  14.  
  15. check(char *command, char *reply, int timeout)
  16. {
  17.     type(command);
  18.     return prompt(reply, timeout);
  19. }
  20.  
  21. /* ----- Wait for prompt and send command ------------------------------ */
  22.  
  23. answer(char *hint, char *command)
  24. {
  25.     int result;
  26.  
  27.     if (result = prompt(hint, TIMEOUT))
  28.         return result;    /* Timeout or cancel */
  29.     pause(60);            /* Don't type immediatly */
  30.     type(command);
  31.     return 0;
  32. }
  33.  
  34. /* ----- Main program -------------------------------------------------- */
  35.  
  36. main()
  37. {
  38.     char name[32];
  39.     int year, month, day, hour, minute, second, weekday;
  40.     int go = 1;
  41.  
  42.     setup(
  43.         2,        /* 1200 baud */
  44.         1,        /* 8 data */
  45.         0,        /* no parity */
  46.         0,        /* 1 stop */
  47.         -1,        /* port: no change */
  48.         -1,        /* DTR: no change */
  49.         0);        /* Handshake: none */
  50.     type("AT\r");
  51.     pause(60);
  52.  
  53.     while (go) {
  54.         if (check("AT\r", "OK", 60))
  55.             break;
  56.         pause(30);
  57.         /* Modem setup */
  58. /*        if (check("ATB0S7=60S10=14S9=12\r", "OK", 60))
  59.             break;
  60.         pause(60); */
  61.         /* Dial and log into LUXPAC */
  62.         if (check("ATDP0735\r", "CONNECT", TIMEOUT))
  63.             break;
  64.         if (answer("LUXPAC", "N...-0228464510003\r"))
  65.             break;
  66.         /* Now log into CompuServe */
  67.         if (answer("ID", "73720,2200\r"))
  68.             break;
  69.         if (answer("word", "...\r"))
  70.             break;
  71.         go = 0;            /* Ok */
  72.     }
  73.     if (go) {        /* Timeout or cancel */
  74.         setdtr(0);    /* Negate DTR: modem hangs up */
  75.         pause(60);    /* Wait one second */
  76.         setdtr(1);    /* Assert DTR: now back in command mode */
  77.         beep();        /* If error */
  78.         return;
  79.     }
  80.  
  81.     /* Get Macintosh date and time */
  82.  
  83.     date(time(), &year, &month, &day, &hour, &minute, &second, &weekday);
  84.  
  85.     /* Use date and time to build a unique file name */
  86.  
  87.     format(name, "CIS %04i%02i%02i%02i%02i%02i",
  88.         year, month, day, hour, minute, second);
  89.  
  90.     /* Start capturing incoming data into that file */
  91.  
  92.     if (capture(1, name)) {
  93.         beep();        /* If error */
  94.         return;
  95.     }
  96.  
  97.     /* The following text is displayed and also captured into the file */
  98.  
  99.     display("*** CIS session %02i-%02i-%04i %02i:%02i:%02i ***\r\r",
  100.         day, month, year, hour, minute, second);
  101. }
  102.